﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.ComponentModel;
using System.Web.UI;
using System.Drawing.Design;

namespace Lilium.Web.Mvc.AjaxControlToolkit
{
	[RequiredResource(typeof(CommonToolkitScripts))]
	[ToolkitScriptReference("NumericUpDown.NumericUpDownBehavior.js", LoadOrder = 1)]
	public class NumericUpDownExtender: ToolkitExtenderBase
	{
		public NumericUpDownExtender(string elementID)
			: base("AjaxControlToolkit.NumericUpDownBehavior", elementID)
		{
		}

		public static object CreateNumericUpDownValue(int value)
		{
			return new { d= value };
		}

		#region public string TargetButtonUpID

		private string m_TargetButtonUpID;

		/// <summary>
		/// Control to Up
		/// </summary>
		//[IDReferenceProperty(typeof(Control))]
		[SuppressMessage("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase", Justification = "Following ASP.NET AJAX pattern")]
		[ExtenderControlProperty()]
		public string TargetButtonUpID { [DebuggerNonUserCodeAttribute] get { return m_TargetButtonUpID ?? ""; } [DebuggerNonUserCodeAttribute] set { m_TargetButtonUpID = value; } }

		#endregion

		#region public string TargetButtonDownID

		private string m_TargetButtonDownID;

		/// <summary>
		/// Control to Down
		/// </summary>
		//[IDReferenceProperty(typeof(Control))]
		[SuppressMessage("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase", Justification = "Following ASP.NET AJAX pattern")]
		[ExtenderControlProperty()]
		public string TargetButtonDownID { [DebuggerNonUserCodeAttribute] get { return m_TargetButtonDownID ?? ""; } [DebuggerNonUserCodeAttribute] set { m_TargetButtonDownID = value; } }

		#endregion

		#region public string ServiceUpPath

		private string m_ServiceUpPath;

		/// <summary>
		/// Path to the helper web service
		/// </summary>
		[TypeConverter(typeof(ServicePathConverter))]
		[UrlProperty()]
		[Editor("System.Web.UI.Design.UrlEditor", typeof(UITypeEditor))]
		[ExtenderControlProperty()]
		public string ServiceUpPath { [DebuggerNonUserCodeAttribute] get { return m_ServiceUpPath ?? ""; } [DebuggerNonUserCodeAttribute] set { m_ServiceUpPath = value; } }

		private bool ShouldSerializeServiceUpPath()
		{
			return !string.IsNullOrEmpty(ServiceUpMethod);
		}

		#endregion

		#region public string ServiceUpMethod

		private string m_ServiceUpMethod;

		/// <summary>
		/// Method to the helper web service
		/// </summary>
		[ExtenderControlProperty()]
		public string ServiceUpMethod { [DebuggerNonUserCodeAttribute] get { return m_ServiceUpMethod ?? ""; } [DebuggerNonUserCodeAttribute] set { m_ServiceUpMethod = value; } }

		#endregion

		#region public string ServiceDownPath

		private string m_ServiceDownPath;

		/// <summary>
		/// Path to the helper web service
		/// </summary>
		[TypeConverter(typeof(ServicePathConverter))]
		[UrlProperty()]
		[Editor("System.Web.UI.Design.UrlEditor", typeof(UITypeEditor))]
		[ExtenderControlProperty()]
		public string ServiceDownPath { [DebuggerNonUserCodeAttribute] get { return m_ServiceDownPath ?? ""; } [DebuggerNonUserCodeAttribute] set { m_ServiceDownPath = value; } }

		[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
		private bool ShouldSerializeServieDownPath()
		{
			return !string.IsNullOrEmpty(ServiceDownMethod);
		}

		#endregion

		#region public string ServiceDownMethod

		private string m_ServiceDownMethod;

		/// <summary>
		/// Method to the helper web service
		/// </summary>
		[ExtenderControlProperty()]
		public string ServiceDownMethod { [DebuggerNonUserCodeAttribute] get { return m_ServiceDownMethod ?? ""; } [DebuggerNonUserCodeAttribute] set { m_ServiceDownMethod = value; } }

		#endregion

		#region public double Step

		private double m_Step = 1.0;

		/// <summary>
		/// Step used for simple numeric incrementing and decrementing
		/// </summary>
		[DefaultValue(1.0)]
		[ExtenderControlProperty]
		public double Step { [DebuggerNonUserCodeAttribute] get { return m_Step; } [DebuggerNonUserCodeAttribute] set { m_Step = value; } }

		#endregion


		#region public double Minimum

		private double m_Minimum = double.MinValue;

		/// <summary>
		/// Minimum Value
		/// </summary>
		[ExtenderControlProperty]
		public double Minimum { [DebuggerNonUserCodeAttribute] get { return m_Minimum; } [DebuggerNonUserCodeAttribute] set { m_Minimum = value; } }

		#endregion

		#region public double Maximum

		private double m_Maximum = double.MaxValue;

		/// <summary>
		/// Maximum Value
		/// </summary>
		[ExtenderControlProperty]
		public double Maximum { [DebuggerNonUserCodeAttribute] get { return m_Maximum; } [DebuggerNonUserCodeAttribute] set { m_Maximum = value; } }

		#endregion

		#region public string RefValues

		private string m_RefValues;

		/// <summary>
		/// List for RefValue
		/// </summary>
		[Editor("System.ComponentModel.Design.MultilineStringEditor", typeof(UITypeEditor))]
		[ExtenderControlProperty()]
		public string RefValues { [DebuggerNonUserCodeAttribute] get { return m_RefValues ?? ""; } [DebuggerNonUserCodeAttribute] set { m_RefValues = value; } }

		#endregion

		#region public int Width

		private int m_Width;

		/// <summary>
		/// TextBox + Button Width 
		/// </summary>
		[RequiredProperty()]
		[ExtenderControlProperty()]
		public int Width { [DebuggerNonUserCodeAttribute] get { return m_Width; } [DebuggerNonUserCodeAttribute] set { m_Width = value; } }

		#endregion

		#region public string Tag

		private string m_Tag;

		/// <summary>
		/// Custom parameter for call WebService method
		/// </summary>
		[ExtenderControlProperty()]
		public string Tag { [DebuggerNonUserCodeAttribute] get { return m_Tag ?? ""; } [DebuggerNonUserCodeAttribute] set { m_Tag = value; } }

		#endregion
	}
}